-
Notifications
You must be signed in to change notification settings - Fork 102
Client refactor #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client refactor #88
Conversation
Codecov Report
@@ Coverage Diff @@
## master #88 +/- ##
==========================================
+ Coverage 91.46% 93.19% +1.72%
==========================================
Files 6 6
Lines 293 294 +1
==========================================
+ Hits 268 274 +6
+ Misses 25 20 -5
Continue to review full report at Codecov.
|
4c28722
to
f656758
Compare
Thank you @3lnc! I've added this to our backlog for a code review. |
python_http_client/client.py
Outdated
@@ -62,6 +63,9 @@ def to_dict(self): | |||
class Client(object): | |||
"""Quickly and easily access any REST or REST-like API.""" | |||
|
|||
# These are the supported HTTP verbs | |||
methods = set(('delete', 'get', 'patch', 'post', 'put')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set
literal instead?
methods = {'delete', 'get', 'patch', 'post', 'put'}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At time this PR was created, http client claimed support for 2.6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@3lnc
Since that doesn't seem to be the case now... set literal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the supported versions going forward: https://github.com/sendgrid/sendgrid-python/blob/v4/.travis.yml#L4
tests/test_unit.py
Outdated
@@ -84,7 +90,7 @@ def test__init__(self): | |||
self.assertEqual(default_client.host, self.host) | |||
self.assertEqual(default_client.request_headers, {}) | |||
self.assertIs(default_client.timeout, None) | |||
methods = ['delete', 'get', 'patch', 'post', 'put'] | |||
methods = set(('delete', 'get', 'patch', 'post', 'put')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set
literal?
methods = {'delete', 'get', 'patch', 'post', 'put'}
tests/test_unit.py
Outdated
@@ -97,7 +103,7 @@ def test__init__(self): | |||
timeout=10) | |||
self.assertEqual(client.host, self.host) | |||
self.assertEqual(client.request_headers, request_headers) | |||
methods = ['delete', 'get', 'patch', 'post', 'put'] | |||
methods = set(('delete', 'get', 'patch', 'post', 'put')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set
literal?
methods = {'delete', 'get', 'patch', 'post', 'put'}
tests/test_unit.py
Outdated
self.client._update_headers({'X-test': 'Test'}) | ||
self.client.get() | ||
request = maker.call_args[0][1] | ||
self.assertTrue('X-test' in request.headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.assertIn('X-test', request.headers)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Available since 3.1, client provides support for 2.7 (2.6 previously)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@3lnc
New in version 2.7.
@3lnc Please address conflicts and code coverage failures. Thanks! |
Hi @3lnc, When you get a moment to make the updates I'd love to merge this before we release v4 of the sendgrid-python library which will depend on this library. Thanks! With Best Regards, Elmer |
4313ca7
to
bdb061c
Compare
bdb061c
to
22e6d1e
Compare
request.add_header('Content-Type', 'application/json') | ||
request = urllib.Request( | ||
self._build_url(query_params), | ||
headers=self.request_headers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes an issue I am having when adding headers... request.add_header(key, value)
capitalizes the header which some APIs don't seem to want. :-\
Hello @3lnc, |
Fixes
Checklist
Short description of what this PR does:
Better signatures for client; minor refactoring